package com.amsp.oa.oademo.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.amsp.oa.oademo.entity.GongzuobxhpbEntity;
import com.amsp.oa.oademo.mapper.GongzuobxhpbMapper;
import com.amsp.oa.oademo.service.GongzuobxhpbService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

@Service
public class GongzuobxhpbServiceImpl extends ServiceImpl<GongzuobxhpbMapper, GongzuobxhpbEntity>
        implements GongzuobxhpbService {
    @Override
    public IPage<GongzuobxhpbEntity> queryPage(Long page, Long limit, String employeeId, String name,
            String department) {
        LambdaQueryWrapper<GongzuobxhpbEntity> wrapper = new LambdaQueryWrapper<>();

        if (StringUtils.isNotBlank(employeeId)) {
            wrapper.like(GongzuobxhpbEntity::getEmployeeId, employeeId);
        }
        if (StringUtils.isNotBlank(name)) {
            wrapper.like(GongzuobxhpbEntity::getName, name);
        }
        if (StringUtils.isNotBlank(department)) {
            wrapper.like(GongzuobxhpbEntity::getDepartment, department);
        }

        wrapper.orderByDesc(GongzuobxhpbEntity::getCreateTime);

        return this.page(new Page<>(page, limit), wrapper);
    }
}